package widget;

import javax.swing.*;
import java.util.HashMap;

/**
 * Created by LLAP on 2017/12/14.x
 * Copyright (c) 2017 LLAP. All rights reserved.
 */
public class TCheckBox extends TComponent {
    public TCheckBox(String name, String comment) {
        super(name, new JCheckBox(comment), comment, false);
    }
    public TCheckBox(String name) {
        this(name, name);
    }

    @Override
    public HashMap<String, Object> getData() throws IllegalArgumentException {
        return new HashMap<String, Object>() {{
            put(name, ((JCheckBox)field).isSelected());
        }};
    }

    @Override
    public void clear() {
        ((JCheckBox)field).setSelected(false);
    }
}
